package com.example.dqhl.recycleviewdemo.activity.eventbus;

import android.app.Activity;
import android.app.LauncherActivity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.TextView;

import com.example.dqhl.recycleviewdemo.R;
import com.example.dqhl.recycleviewdemo.activity.AnimationActivity;
import com.example.dqhl.recycleviewdemo.activity.LoginActivity;
import com.example.dqhl.recycleviewdemo.activity.LuncherActivity;
import com.example.dqhl.recycleviewdemo.event.EventBusMssage;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.util.concurrent.TimeUnit;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Predicate;

/**
 * EventBust Test
 *
 * @author Guanluocang
 *         created at 2018/2/1 15:27
 */
public class EventBusTestActivity extends AppCompatActivity {

    @BindView(R.id.tv_content)
    TextView tvContent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_event_bus_test);
//        ButterKnife.bind(this);


    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        //取消事件注册
        EventBus.getDefault().unregister(this);
    }

    //    当然还要定义一个消息处理的方法：
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onShowMessageEvent(EventBusMssage messageEvent) {
        tvContent.setText("Message from SecondActivity:" + messageEvent.getMessage());
    }

    @OnClick(R.id.tv_content)
    public void onViewClicked() {

        Intent intent = new Intent();
        intent.setClass(EventBusTestActivity.this, SendMessageActivity.class);
        startActivity(intent);
    }
}
